XM.lang.namespace('XM.bejewel');

XM.bejewel.Bejewel = {
    run: function () {
        this._preLoadResource();
    },

    _run: function () {
        XM.canvas.EventTranslator.canvas = GLOBAL_CONFIG['canvas'];

        // register layer and register item event
        XM.canvas.LayerManager.registerLayers(GLOBAL_CONFIG['layer']);

        // start RenderManager
        //XM.canvas.RenderController.paintStep();
        XM.canvas.RenderController.play();
    },

    _preLoadResource: function () {
        var rm = XM.common.ResourceManager;
        rm.preLoad();
        var si = setInterval(function () {
            if (rm.isReady()) {
                clearInterval(si);
                XM.bejewel.Bejewel._run();
            }
        }, 100);
    }
};